﻿using BestTrader.Cms.Core.Extensions;
using BestTrader.Cms.ViewModels;
using FluentValidation;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace BestTrader.Cms.UserCenter.Validation
{
    public class InCashValidation : AbstractValidator<InCashModel>
    {
        public InCashValidation()
        {
            RuleFor(x => x.ManagerId).GreaterThan(0).WithMessage("当前用户不存在");
            RuleFor(x => x.RmmfUserId).NotNull().GreaterThan(0).WithMessage("第三方用户不存在");

            //RuleFor(x => x.Money).GreaterThan(0).LessThanOrEqualTo(6000).WithMessage("单笔最高出金6000美元");
            RuleFor(x => x.Money).Must(IsCheck).WithMessage("单笔最高出金6000美元");


        }

      
        private bool IsCheck(InCashModel entity, decimal arg)
        {
            if (entity.CashType==3 && arg > 6000)
            {
                return false;
            }

            return true;
        }
    }
}
